import request from '@/utils/request'
import type { LoginResponseData, LoginData, WxLoginResponseData } from './type'

enum API {
  GETSMSCODE_URL = '/api/sms/send/',
  LOGIN_URL = '/api/user/login',
  GETWXLOGIN_URL = '/api/user/weixin/getLoginParam'
}

export const getSmsCodeService = (phone: string) =>
  request.get(API.GETSMSCODE_URL + phone)

// 登录
export const goLoginService = (data: LoginData) =>
  request.post<any, LoginResponseData>(API.LOGIN_URL, data)

// 获得微信二维码参数
export const getWxLoginService = (wxRedirectUrl: string) =>
  request.get<any, WxLoginResponseData>(
    API.GETWXLOGIN_URL + `?wxRedirectUrl=${wxRedirectUrl}`
  )
